package com.cn.lycss.servlet;

import com.cn.lycss.model.NewsModel;
import com.cn.lycss.service.NewsService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/home")
public class HomeServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

//        CompanyService companyService=new CompanyService();
//        CompanyModel companyMode =companyService.getCompanyModel();
//        req.setAttribute("companyModel",companyMode);
//
//
//
//        /*    ----------------------------------------------- */
//        NavService navService=new NavService();
//        NavModel[] navModels=navService.getNavModel();
//
//        req.setAttribute("navModels",navModels);
        CommonServlet.setCompanyAndNavDate(req);


        /*
        * 新闻*/
        NewsService newsService=new NewsService();
        NewsModel[] newsModels=newsService.getNewsModelForHomePage();
        req.setAttribute("newsModels",newsModels);
        req.getRequestDispatcher("/jsp/home.jsp").forward(req,resp);
    }
}
